﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using MySchool;

namespace MyKTV
{
    public partial class Form1 : Form
    {
        DBHelper db = new DBHelper();

        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

            db.OpenConnection();
            if (this.textBox1.Text.Trim().Equals(string.Empty)) {
                MessageBox.Show("请输入账号","错误提示框",MessageBoxButtons.OK,MessageBoxIcon.None);
                return;
            }
            if (this.textBox2.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("请输入密码", "错误提示框", MessageBoxButtons.OK, MessageBoxIcon.None);
                return;
            }
            string sql = "select * from admin_info where admin_name='" + textBox1.Text + "'and admin_pwd='" + textBox2.Text + "'";
            SqlCommand command = new SqlCommand(sql,db.Connection);
            SqlDataReader reader = command.ExecuteReader();
            if (!reader.HasRows)
            {
                MessageBox.Show("登陆失败，请检查账号密码是否正确");
                reader.Close();
            }
            else
            {
                MessageBox.Show("成功");
                reader.Close();
                db.OpenConnection();

                wmb.Form20 frm2 = new wmb.Form20();
                frm2.Show();
                return;
            }
            reader.Close();
            db.OpenConnection();
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
